package com.xqh.study.springtxjpa.service;

import com.xqh.study.springtxjpa.dao.CustomerRepository;
import com.xqh.study.springtxjpa.domain.Customer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @ClassName CustomerServiceInAnnotation
 * @Description 注解方式实现事务管理
 * @Author xuqianghui
 * @Date 2019/12/30 21:29
 * @Version 1.0
 */
@Service
public class CustomerServiceInAnnotation {

    @Autowired
    private CustomerRepository customerRepository;

    @Transactional
    public Customer create(Customer customer){
        return customerRepository.save(customer);
    }
}
